package io.github.weiranyi.service.impl;

import io.github.weiranyi.dao.UserDao;
import io.github.weiranyi.service.UserService;

public class UserServiceImpl implements UserService {
    // 【构造注入1】-声明接收userDao的变量 【setter注入2】
    private UserDao userDao;
    // 【构造注入2】-声明接收userDao的变量
//    public UserServiceImpl(UserDao userDao){
//        this.userDao = userDao;
//    }
    public void setUserDao(UserDao userDao){
        this.userDao = userDao;
    }
    @Override
    public void save() {
        /*依赖注入之 手动依赖
            ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
            UserDao userDao = (UserDao) applicationContext.getBean("userDao");
         */
        userDao.save();
    }
}
